import path from 'node:path'
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'
import { watchAndRun } from 'vite-plugin-watch-and-run'
import { modifyPopupHtmlAssetsPath } from './plugins/html'

export default defineConfig({
  plugins: [
    vue(),
    modifyPopupHtmlAssetsPath(),
    watchAndRun([
      {
        watch: path.resolve('src/**/*.*'),
        run: 'pnpm build:dev',
        delay: 500,
      },
    ]),
  ],
  build: {
    outDir: 'dist/popup',
    chunkSizeWarningLimit: 2000,
  },
  server: {
    port: 3010,
    proxy: {
      '/api': {
        target: 'http://127.0.0.1/',
        changeOrigin: true,
      },
    },
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
    },
  },
})
